<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>

<?php
include 'header.php';
include 'menu.php';
?>
</head>
<body>
<br><br><br>
<?php
$gwname = $_GET['name'] or die ("why");
$newrestore = $_GET['restoredir'];
$basepath = $_GET['basep'];
$restorepath = $_GET['restore'];

//echo "$newrestore<br>";
//echo "$gwname<br>";
//echo "$basepath<br>";
//echo "$restorepath<br>";

$cmd = "sudo /opt/fbc/newrestore.sh $gwname $basepath $restorepath $newrestore";

$out = shell_exec($cmd) or die("Something wrong here!");  

if ($out == 0)
{

	$configfile = '/etc/opt/fbc/fbc.xml';
	$x = simplexml_load_file($configfile);

	foreach ($x->server as $s)
	{
		if ($s->name == $gwname)
		{
			$s->restorepath = $restorepath.'/'.$newrestore;
			file_put_contents($configfile, $x->asXML()) or die("save failed");

		}
	}
}

else
{
	echo "Failed to set new restore path!";
}

//  HAVE TO REWRITE XML FILE WITH NEW RESTOREPATH FOR DOM?PO




?>

</body>
</html>



